FROM registry.cn-hangzhou.aliyuncs.com/ontouch-lg-ocr/onetouch-lg-ocr-repo:ocr-base

# 指定工作目录
WORKDIR /ocr/workspace

# 拷贝源代码
COPY . /ocr/workspace

# https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_det_infer.tar
# https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_rec_infer.tar
# https://paddleocr.bj.bcebos.com/PP-OCRv4/chinese/ch_PP-OCRv4_det_infer.tar
# https://paddleocr.bj.bcebos.com/PP-OCRv4/chinese/ch_PP-OCRv4_rec_infer.tar
# https://paddleocr.bj.bcebos.com/PP-OCRv4/chinese/ch_PP-OCRv4_det_server_infer.tar
# https://paddleocr.bj.bcebos.com/PP-OCRv4/chinese/ch_PP-OCRv4_rec_server_infer.tar
# https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/ch_ppstructure_mobile_v2.0_SLANet_infer.tar
# https://paddleocr.bj.bcebos.com/PP-OCRv4/english/en_PP-OCRv4_rec_infer.tar
# 下载模型库
RUN python3 -c 'from modelscope.hub.snapshot_download import snapshot_download;snapshot_download("damo/cv_convnextTiny_ocr-recognition-document_damo", cache_dir="/root/.modelscope/")' \
    && python3 -c 'from modelscope.hub.snapshot_download import snapshot_download;snapshot_download("damo/cv_resnet18_ocr-detection-db-line-level_damo", cache_dir="/root/.modelscope/")' \
    && python3 -c 'from modelscope.hub.snapshot_download import snapshot_download;snapshot_download("damo/cv_dla34_table-structure-recognition_cycle-centernet", cache_dir="/root/.modelscope/")' \
    && python3 -m pip install gunicorn shapely \
    && apt install -y nginx jq gettext-base \
    && mv /ocr/workspace/test/vegeta /usr/local/bin/ \
    && mkdir -p /root/.paddleocr/ /root/.paddleocr/paddleocr_ppstructure_infer /root/.paddleocr/paddleocr_det_infer /root/.paddleocr/paddleocr_det_server_infer /root/.paddleocr/paddleocr_rec_infer /root/.paddleocr/paddleocr_rec_server_infer /root/.paddleocr/paddleocr_cls_infer /root/.paddleclas/inference_model/PULC/text_image_orientation \
    && wget https://paddleocr.bj.bcebos.com/PP-OCRv4/chinese/ch_PP-OCRv4_det_infer.tar -O /root/.paddleocr/paddleocr_det_server_infer.tar \
    && wget https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_det_slim_infer.tar -O /root/.paddleocr/paddleocr_det_infer.tar \
    && wget https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_rec_infer.tar -O /root/.paddleocr/paddleocr_rec_server_infer.tar \
    && wget https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_rec_slim_infer.tar -O /root/.paddleocr/paddleocr_rec_infer.tar \
    && wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar -O /root/.paddleocr/paddleocr_cls_infer.tar \
    && wget https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/ch_ppstructure_mobile_v2.0_SLANet_infer.tar -O /root/.paddleocr/paddleocr_ppstructure_infer.tar \
    && wget https://paddleclas.bj.bcebos.com/models/PULC/inference/text_image_orientation_infer.tar -O /root/.paddleclas/inference_model/PULC/text_image_orientation.tar \
    && tar -xvf /root/.paddleocr/paddleocr_det_server_infer.tar -C /root/.paddleocr/paddleocr_det_server_infer --strip-components 1 \
    && tar -xvf /root/.paddleocr/paddleocr_det_infer.tar -C /root/.paddleocr/paddleocr_det_infer --strip-components 1 \
    && tar -xvf /root/.paddleocr/paddleocr_rec_server_infer.tar -C /root/.paddleocr/paddleocr_rec_server_infer --strip-components 1 \
    && tar -xvf /root/.paddleocr/paddleocr_rec_infer.tar -C /root/.paddleocr/paddleocr_rec_infer --strip-components 1 \
    && tar -xvf /root/.paddleocr/paddleocr_cls_infer.tar -C /root/.paddleocr/paddleocr_cls_infer --strip-components 1 \
    && tar -xvf /root/.paddleocr/paddleocr_ppstructure_infer.tar -C /root/.paddleocr/paddleocr_ppstructure_infer --strip-components 1 \
    && tar -xvf /root/.paddleclas/inference_model/PULC/text_image_orientation.tar -C /root/.paddleclas/inference_model/PULC/text_image_orientation --strip-components 1 \
    && rm -f /root/.paddleocr/paddleocr_det_infer.tar /root/.paddleocr/paddleocr_det_server_infer.tar /root/.paddleocr/paddleocr_rec_infer.tar /root/.paddleocr/paddleocr_server_rec_infer.tar /root/.paddleocr/paddleocr_cls_infer.tar /root/.paddleclas/inference_model/PULC/text_image_orientation.tar